import React from 'react';
import { BrowserRouter as Router, Route, Switch, Redirect } from 'react-router-dom';
import Layout from '@/components/Layout';
import Login from '@/view/Login';
import 'antd/dist/antd.less';

function App() {
  return (
    <>
      <Router>
        <Switch>
          <Route exact path='/login'>
            <Login />
          </Route>
          <Route
            path="/"
            render={() => {
              if (!sessionStorage.getItem('info')) return <Redirect to="/login" />;
              return <Layout />;
            }}
          />
        </Switch>
      </Router>
    </>
  );
}

export default App;
